package gentle.controller;

import gentle.entity.*;
import gentle.service.IDoctorDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import gentle.util.ToolUtil;
import gentle.exception.BussinessException;
import gentle.exception.BizExceptionEnum;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 医生看诊/update
 *
 * @author py
 * @Date 2018年4月19日23:15:54
 */
@Controller
@RequestMapping("/doctorDetails")
public class DoctorDetailsController{
    @Autowired
    IDoctorDetailsService doctorDetailsService;

    //病历
    @RequestMapping(value = "/medicalRecord", method = RequestMethod.POST)
    @ResponseBody
    public DotorCaseInfo medicalRecord(String reservationsId,String areaAbbreviation,String roleName){
        DotorCaseInfo dotorCaseInfo=doctorDetailsService.medicalRecords(reservationsId,areaAbbreviation);
        dotorCaseInfo.setMedicalUpPermission(doctorDetailsService.getMedicalUpPermission(roleName));
        return dotorCaseInfo;
    }

    //随访记录
    @RequestMapping(value = "/doctorFollow", method = RequestMethod.POST)
    @ResponseBody
    public DotorFollowsInfo doctorFollow(String reservationsId,String userAccount,String areaAbbreviation,String abbreviation){
        DotorFollowsInfo dotorFollowsInfo=doctorDetailsService.doctorFollow(reservationsId,areaAbbreviation,abbreviation);
        dotorFollowsInfo.setSfList(doctorDetailsService.getSfList(userAccount));
        dotorFollowsInfo.setJgList(doctorDetailsService.getJgList(userAccount));
        dotorFollowsInfo.setUserName(userAccount);
        return dotorFollowsInfo;
    }

    /**
     * 医生回访数据列表
     */
    @RequestMapping(value = "/followTableList/{reservationsId}/{abbreviation}")
    @ResponseBody
    public List<DoctorRevisitInfo> FollowTableList(@PathVariable String reservationsId,@PathVariable String abbreviation) throws Exception {
        if (ToolUtil.isEmpty(reservationsId)|| ToolUtil.isEmpty(abbreviation)) {
            throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
        }
        return doctorDetailsService.FollowTableList(reservationsId,abbreviation);
    }

}